package comparators;

import java.util.Comparator;

import bookworm.Book;

public class ComparatorOfBooks implements Comparator<Object>
{
	@Override
	public int compare(Object arg0, Object arg1) 
	{
		 Book book0 = (Book) arg0;
		 Book book1 = (Book) arg1;
		 
		 int ratingBook0 = book0.getAverageRatingFromABook();
		 int ratingBook1 = book1.getAverageRatingFromABook();
		 
		 if(ratingBook0  > ratingBook1)
		 {
			 return -1;
		 }
		 else if (ratingBook0 == ratingBook1)
		 {
			 return 0;
		 }
		 else
		 {
			 return 1;
		 }
	}
}
